from tornado.web import app_log as log
from custom_func.crypt_func import *
import time
import json


class MockHandler(object):
    def __init__(self):
        self.key = '6615162675826787'
        self.zxPublicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCE5nK0Wf6e7yO5JE61qJwNUmcRt/GOk1SFVBWQYGQEXYn7tz3ZiDIgNasPOYZ6g6pbic9kR2FBwTj646E8vKIC37ZLUgTaIsLLIOtxxHa3YrM7xqYaUWz5Ua4yttM6D7bdc7hOaqLXSslYvNT1NDoSkphtILPQtX2aUOmT3eoMHQIDAQAB'
        self.merchantPrivateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMFeYKy9ZZN7bI6m23b2365GpDFhuKxS3WpyKS/tTB/RJU0RSqiowPEBZHGsGmEhue9AjNwtocjuc5F+HrAg248HhBVY4waWZPgDMLddmpHPn2K7Smdv9nwyzo3MaAayDmuy4A/vB24yaixfUoHdix/7Kagw40rjCnNG1CxcL9YRAgMBAAECgYBrxVwAKnboYcu5HcoHXcSA7yIn25z/fhelcgb+jTT2LqypbU+8/IC8UdhXemIhbJiifcmEFXKr+Co1FqOn6kgzURxFn5im2KMWitnCEEERAEa+GGWLM0lRXydI+K65S4Dc2cVDksEyW1YhtzZsocPnyMuzWLcBY9HN0V8v5HhseQJBAOOrgdlyM5khcF2vdl/nmxqCqLPBPby7zUpAmevurVWv5diOYhbc4CbRdJuSrYFqy8cu9K2NRaRvJCxbtM/j2s8CQQDZbjFgeW2CG3W3+k1FKns7kavdJlCe4ubOej5IEJjbrJyDt/uVt+J363D0CdCEjHn2BqSfphK8z6N3SW4BK/kfAkBiXESbR0WXkOTU9Ot1f8B48Z4lGwWrNo/41nQphFKKxJXOu6URL5f/7VotpG8ljJhBk73OBUzjP8knCO/TKSPtAkEAkT28mhdDAYBaWHVJHITOIPKj/WxUum4Tg6XA6N69XTCmtI437sEQ9M4/e6T6tzAnYCL74PFM3vdM2KgiZYH8PQJAQvGrb+DGy8rHLt/VE2ufLqDoNoQq/wAOFL3BvsoHh/grhKAF5JimuWKyCOGDKIIdu/g6p9WHZ1tjAQ6O8VFYwQ=='
        self.merchantCode = 'NEO200000'
        self.url = 'http://172.20.77.15:9038/loan/api/import/loan'

    def loan(self):
        data = dict(transId=int(time.time()*1000),
                    contractId=int(time.time()*1000),
                    sourceCompany='普惠',
                    belonCompany='f',
                    companyType='n',
                    signZone='0',
                    signTime='2017/02/20',
                    periodType='0',
                    period='100',
                    repayType='0',
                    amount='55555.55',
                    lendAmount='4444.44',
                    singleFee='10.11',
                    futuresFee='10.12',
                    intermediaryFee='10.13',
                    monthFee='10.14',
                    merchantFee='10.21',
                    insuranceFee='16.811',
                    exitCharge='100.11',
                    serviceCharge='100.22',
                    productType='11',
                    loanCategory='f2',
                    loanFeeType='借款费用类别1',
                    type='0',
                    accountType='0',
                    idCardType='1',
                    idCardNo='330522198604085112',
                    borrowerName='焙洎痕',
                    borrowBankCardNo='6222083173013803266',
                    borrowBankType='CDB',
                    borrowProvince='广东省',
                    borrowCity='深圳市',
                    borrowBranch='中国工商银行南山支行',
                    receiverName='赇觋干',
                    receiverIdCardType='1',
                    receiverIdCardNo='150921197706270615',
                    receiverMobile='18806081151',
                    receiverBankCardNo='6222031811774335878',
                    receiverBankType='CDB',
                    receiverProvince='广东省',
                    receiverCity='深圳市',
                    receiverBranch='农业银行南山支行',
                    auditOpinion='风控意见风控意见风控意见风控意见风控意见',
                    purpose='个人消费',
                    idCardUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptIdCardUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    commonIdcardUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptCommonIdcardUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    drivingLicenseUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptDrivingLicenseUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    mortgageBookUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptMortgageBookUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    notarialCertUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptNotarialCertUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    proxyStatementUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptProxyStatementUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    premisesPermitUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptPremisesPermitUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    projectApplyFormUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptProjectApplyFormUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    auditOpinionBookUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptAuditOpinionBookUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    finalEmailReplyUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptFinalEmailReplyUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    foreclosureCardUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptForeclosureCardUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    loanApprovalEmailUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptLoanApprovalEmailUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    otherCertUrl='/loan-private-xnol/58eb342b18d01c30716777c7.jpg,/loan-private-xnol/58eb342b18d01c30716777h7.jpg',
                    encryptOtherCertUrl='/loan-common-xnol/58eb345418d01c30716777c8.jpg,/loan-common-xnol/58eb345418d01c30716777h8.jpg',
                    creditReportUrl='/loan-private-xnol/58eb342b18d01c30716777c71.jpg,/loan-private-xnol/58eb342b18d01c30716777h71.jpg',
                    encryptCreditReportUrl='/loan-private-xnol/58eb342b18d01c30716777c81.jpg,/loan-private-xnol/58eb342b18d01c30716777h81.jpg',
                    notifyUrl='http://172.20.20.160:8280/xnzx-test-project/import/loan/notity.action',
                    auditNotifyUrl='http://172.20.20.160:8280/xnzx-test-project/import/loan/audit/notity.action',
                    repaySource='还款来源',
                    repaySafeguards='还款保障措施',
                    mortgage=dict(mortgageType='1',
                                  holder='',
                                  city='',
                                  houseArea='',
                                  vehicleType='轿车',
                                  carNo='11111111',
                                  mileage='100',
                                  purchaseAmt='1000000',
                                  valuationAmt='1000000',
                                  registTime='2017/04/10',
                                  remark=''),
                    undueLoanInfo=dict(fundUse='借款人资金运用情况',
                                       financialCondition='借款人经营状况及财务状况',
                                       repayAbilityChange='借款人还款能力变化情况',
                                       overdue='借款人逾期情况',
                                       litigation='借款人涉诉情况',
                                       punishment='借款人受行政处罚情况'),
                    detail='借款详情借款详情借款详情借款详情借款详情')
        data = aes_encode_to_b64(json.dumps(data), self.key)
        log.info(data)
        return data
